1 using UnityEngine;
2 using
System.Collections;
3
4 public
class SimpleFPSCounter : MonoBehaviour
5 {
6
7     
public bool active = false;
8
9     
private float elapsedTime;
10     
private float numFrames;
11     
private float fps;
12
13     
void Update()
14     {
15         
if (!active) return;
16         
17         numFrames++;
18         elapsedTime += Time.deltaTime;
19         
if (elapsedTime >= 1f)
20         {
21             fps = numFrames / elapsedTime;
22             numFrames =
0;
23             elapsedTime =
0;
24         }
25         print(Mathf.RoundToInt(fps));
26     }
27 }


Gõ tìm kiếm nhanh...